﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class shop_HotSpot_Edit : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            ReadAction();
            if (this.hAction.Value == "Edit")
            {
                BindData();
            }
        }
    }

    private void ReadAction()
    {
        this.hAction.Value = Shove._Web.Utility.GetRequest("Action");
        this.hMasterID.Value = Shove._Web.Utility.GetRequest("ID");
    }
    
    private void BindData()
    {
        string ID = this.hMasterID.Value;
        DataTable dt = new DAL.Tables.tbl_Site_HotSpot().Open("", "ID=" + ID, "");

        if (dt == null)
        {
            PublicFunction.GoError(ErrorNumber.NoData, "", "");

            return;
        }

        txtName.Text = dt.Rows[0]["Name"].ToString();        
    }

    protected void btnCancle_Click(object sender, EventArgs e)
    {
        Response.Redirect("HotSpot_Manager.aspx");
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        long ID = Shove._Convert.StrToLong(this.hMasterID.Value, 1);

        DAL.Tables.tbl_Site_HotSpot tbl_HotSpot = new DAL.Tables.tbl_Site_HotSpot();
        tbl_HotSpot.ShopID.Value = _Site.ID;
        tbl_HotSpot.Name.Value = txtName.Text;
             
        if (this.hAction.Value == "Add")                      //添加操作 
        {
            tbl_HotSpot.Insert();
        }
        else if (this.hAction.Value == "Edit")             //修改操作
        {

            tbl_HotSpot.Update("ID=" + ID);
        }

        Response.Redirect("HotSpot_Manager.aspx");
    }
}
